﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.SessionState;
using System.Web;

namespace AjaxLibrary
{
    public class orderInvoice : IHttpHandler, IRequiresSessionState
    {
        #region IHttpHandler 成员

        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            string param = context.Request.QueryString["Param"];

            switch (param)
            {
                case "updateOrderInvoice":
                    insertUpdateOrderInvoice(context.Request,context.Response);
                    break;
                default:
                    context.Response.Output.Write("Unknown Request URL.");
                    break;
            }
        }

        private void insertUpdateOrderInvoice(HttpRequest request, HttpResponse response)
        {
            int adminId = logic.sysAdmin.AdminID;
            int orderId = 0;
            int.TryParse(request.QueryString["orderId"], out orderId);
            string invoiceCode = request.QueryString["invoiceCode"];

            bool isAffected = DAL.OrderInvoice.insertUpdate(orderId,invoiceCode,adminId);

            string result = isAffected ? "1" : "0";
            response.Output.Write(result);
        }

        #endregion
    }
}
